import reshandler from '../response-handler'
import Vue from 'vue'
function makeData(res) {
	let resArr = []
	console.log(res.postList[0])
	res.postList.forEach(val =>{
		let data =  {
			shop:'',
			id:val.id,
			refId:val.refId,
			postType:val.postType,
			title: val.title,
			content: val.content,
			name:val.author.name,
			time:val.publishDate,
			attendNum:val.commentCount, // 评论数量
			followCount:val.followCount,   // 关注数量
			isSupport:val.hasFollow,
	//		video:'http://www.carowl.cn/upload/shop/256181ec2e324ce5a563a1184fcda130/media/201802/040740a4-950c-4235-a11a-4bc6f359ba83.mp4',
			images:val.images?[]:'',
			avatar:val.author.head?val.author.head:'',
			audios:val.audios?val.audios[0]:'',
			videos:val.videos?val.videos[0]:'',
			topics:val.topics,
			page:'community'
		}
		val.images && val.images.forEach(img=>{
			console.log(img)
			img&&data.images.push(img)
		})
		resArr.push(data)
	})
	return resArr
}
function getNew(params){
	let that = this
	return new Promise(function (resolve, reject) {
		params = Object.assign({}, params, {
			methodName: "ListPostByFleet",
		  })
        that.$.get(params).then(resp => {
            resolve(resp)
        }).catch(err => {
            reject(err)
        })
    })
}
export default function(params, success, fail) {
	getNew.bind(this)(params)
	.then(reshandler.success(success, fail, makeData), reshandler.error(fail))
//	success({
//		title: '适宜旅游去哪里',
//		content: '这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容',
//		name:'长春卡欧车友会',
//		time:'10:48',
//		attendNum:'111',
//		star:'10',
//		video:'http://www.carowl.cn/upload/shop/256181ec2e324ce5a563a1184fcda130/media/201802/040740a4-950c-4235-a11a-4bc6f359ba83.mp4'
//		images:[icon1,icon2,icon3,icon4],
//		avatar:'',
//	})
}